#include <iostream>
#include <typeinfo>
using namespace std;
class Flyable{
public:
    virtual void takeoff()=0;
    virtual void land()=0;
};
class Bird:public Flyable{
public:
    void foraging(){
        cout<<"Bird foraging"<<"\n";
    };
    virtual void takeoff(){
        cout<<"Bird Take Off"<<"\n";
    };
    virtual void land(){
        cout<<"Bird Land On"<<"\n";
    };
};
class Plane:public Flyable{
public:
    void carry(){
        cout<<"Plane Take Off"<<"\n";
    };
    virtual void takeoff(){
        cout<<"Plane Take Off"<<"\n";
    };
    virtual void land(){
        cout<<"Plane Land On"<<"\n";
    };
};
void dosomething(Flyable *obj)
{
    cout<<"Object Name:"<< typeid(*obj).name()<<"\n";
    obj->takeoff();
    if(typeid(*obj) == typeid(Bird))
    {
        Bird *b = dynamic_cast<Bird*>(obj);
        b->foraging();
    }
    if(typeid(*obj) == typeid(Bird))
    {
        Plane *p = dynamic_cast<Plane*>(obj);
        p->carry();
    }
    obj->land();
}
int main() {
    Bird b;
    Plane p;
    dosomething(&b);
    dosomething(&p);
    //type ID测试
    Plane *p1 = new Plane();
    cout<<"Plane's type:"<<typeid(p1).name()<<"\n";
    cout<<"*Plane's type:"<<typeid(*p1).name()<<"\n";
    return 0;
}